class SiteController < ApplicationController
  layout 'entries'
  
  def login
    session[:rluser] = nil
  end
  
  def login_authenticate
    if (user = User.authenticate(params['login']['email'], params['login']['password']))
      session[:rluser] = user.id
      if (session['return_to'])
        redirect_to session['return_to'], :protocol => 'http://'
        session['return_to'] = nil
      else
        redirect_to '/', :protocol => 'http://'
      end
    else
      flash[:notice] = 'Invalid email or password.'
      redirect_to :action => :login
    end
  end

  def logout
    session[:rluser] = nil
    flash[:notice] = 'You have been logged out.'
    redirect_to :action => :login
  end
end
